package cn.edu.ctbu.studentstest.controller;

import cn.edu.ctbu.studentstest.domain.Students;
import cn.edu.ctbu.studentstest.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
public class StudentController {
    @Autowired
    StudentService studentService;
    @RequestMapping("/students/list")
    public String list(Model model){
        List<Students> students=studentService.findAll();
        model.addAttribute("data",students);
        return "/students/list";
    }
    @RequestMapping("/findByName")
    public String findByName(Model model,String name){
        List<Students> students=studentService.findByStudentName(name);
        model.addAttribute("data",students);
        return "/students/list";
    }
}
